<template>
  <div class="auto" style="margin-top: 10px;border: 1px solid #F2F6FA;">
    <criteria v-ref:criteria>
      <div novalidate class="form-horizontal" partial>
        <p class="flex-between bg-info" style="padding: 8px;">
          <span>收费查询</span>
          <span class="btn btn-link add-postition" @click="$parent.clear()">清空查询条件</span>
        </p>
        <div class="form-group">
          <label class=" col-sm-3 control-label">付款方式</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_payment"
                v-model="model.f_payment"
                :options='$parent.payments' placeholder='请选择'
                condition="all_付款方式_14 = '{}  '"
                close-on-select></v-select>
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">收费类型</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_feetypes"
                v-model="model.f_feetypes"
                :options='$parent.feetypes' placeholder='请选择'
                condition="all_收费类型_15 = '{}'"
                close-on-select></v-select>
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">气价名称</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_price_name"
                v-model="model.f_price_name"
                :options='$parent.pricenames' placeholder='请选择'
                condition="all_气价名称_31= '{}'"
                close-on-select></v-select>
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">气量大于</label>
          <div class="col-sm-9">
            <input  type="text" class="form-control" v-model="model.f_user_name"
            condition="all_气量_11 > '{}'"
            :size="model.f_user_name ? model.f_user_name.length : 1">
          </div>
        </div>
      </div>
    </criteria>
  </div>
</template>

<script>
import AppData from '../../../../stores/AppData'
import * as Util from '../../../Util'
export default {
  title: '收费查询条件',
  methods: {
    getArgs () {
      console.log('2222', this.$refs)
      return this.$refs.criteria.search()
    },
    // 清空所有查询条件
    clear () {
      Object.keys(this.$refs.criteria.model).forEach((key) => {
        this.$refs.criteria.model[key] = ''
      })
    }
  },
  computed: {
    payments () {
      return [{label: '全部', value: ''}, ...AppData.getParam('付款方式')]
    },
    feetypes () {
      return [{label: '全部', value: ''}, ...AppData.getParam('收费类型')]
    },
    pricenames () {
      let arr = []
      if (Util.f.parent.orgtype === '总公司') {
        AppData.getOnlyPrice().forEach((item) => {
          let temp = {}
          temp.label = item.label
          temp.value = item.value.f_price_name
          arr.push(temp)
        })
      } else {
        AppData.getOnlyPrice().forEach((item) => {
          console.log('看看气价的分公司..', item.value, Util.f.f_filiale)
          if (item.value) {
            if (Util.f.f_fengongsi === item.value.f_filiale) {
              let temp = {}
              temp.label = item.label
              temp.value = item.value.f_price_name
              arr.push(temp)
            }
          }
        })
      }
      return [{label: '全部', value: ''}, ...arr]
    }
  }
}
</script>
